﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentHookups.WCF;

namespace StudentHookups
{
    public partial class SearchResults : System.Web.UI.Page
    {
        WCFClient client = new WCFClient();
        protected void Page_Load(object sender, EventArgs e)
        {
            
            List<UserComposite> users = new List<UserComposite>();
            
            //gets search parameter from url
            string searchkey = Request.QueryString.Keys[0];

            lblsearchParameters.Text = "You searched for " + searchkey + ": " + Request.QueryString[0];
            if(searchkey == "Username")
                users = client.getUsersByUsername(Request.QueryString[0]);
            if (searchkey == "Firstname")
                users = client.getUsersByFirstname(Request.QueryString[0]);
            if (searchkey == "Lastname")
                users = client.getUsersByLastname(Request.QueryString[0]);
            //Databinding result
            DataSet ds = new DataSet();
            displayResults.DataSource = users;
            displayResults.DataBind();
            
        }
    }
}